<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main" />
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
    <g:set var="entityName" value="${message(code: 'estate.label', default: 'Estate')}" />
    <title>舆情预警</title>
    <style>
    .contact-stat{
        padding: 8px 0px;
        text-align: center;
    }
    .contact-stat span{
        font-size: 13px;
        color: #88898c;
        margin-bottom: 10px;
    }
    .contact-stat strong{
        font-size: 13px;
        word-wrap: break-word;
    }
    .nav-tabs{
        border-bottom: none;
    }
    .hpanel > .panel-footer, .hpanel > .panel-section{
        background: #f9f9f9;
    }

    .newFontSize{
        font-size: 12px;
    }
    table>tbody>tr>td, table>tbody>tr>th,.table>tfoot>tr>td, table>tfoot>tr>th, table>thead>tr>td, table>thead>tr>th{
        padding: 8px;
        line-height: 1.42857143;
    }
    .tdColor{
        color: red !important;
    }

    </style>
</head>
<body class="fixed-navbar fixed-sidebar">

<div class="small-header">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right">
                <ol class="hbreadcrumb breadcrumb">
                    <li>CINDATA PLS</li>
                    <li class="active">
                        <span>舆情预警</span>
                    </li>
                </ol>
            </div>

            <h2 class="font-light m-b-xs">
                舆情预警
            </h2>
        </div>
    </div>
</div>

<div class="content animate-panel">
    <div class="row">
        <g:form method="POST" action="publicOpinionWarning" class="form-horizontal" role="form" id="form">
            <div class="hpanel hblue">
                <div class="panel-heading">
                    <div class="panel-tools">
                        <button class="btn btn-primary btn-xs" type="submit" id="searchBtn"><i class="fa fa-search"></i> 查询</button>
                        <button class="btn btn-warning2 btn-xs" type="button" id="resetBtn">
                            <i class="fa fa-times"></i> 重置</button>
                    </div>
                    查询
                </div>
             <div class="panel-body seach-group" id="bug1">

                <div class="row">

                    <div class="form-group col-sm-4">
                        <label for="district" class="col-sm-3 control-label">城市</label>
                        <div class="col-sm-9">
                            <g:select class="form-control" name="city" id="city"
                                      from="${com.cindata.City.executeQuery("select distinct e.city as city from Estate e where e.city.id not in(2,1660)")}"
                                      valueMessagePrefix="status" optionKey="zoneNumber" optionValue="name"
                                      value="${params?.city}"
                                      noSelection="${["-1": '请选择城市']}"/>
                            <input type="hidden" id="communityId" value="${params?.communityId}" name="communityId" />
                        </div>
                    </div>

                    <div class="form-group col-sm-4">
                        <label  class="col-sm-3 control-label">小区名称</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="communityName" id="communityName" value="${params?.communityName}" placeholder="请输入小区名称">
                        </div>
                    </div>
            <div class="form-group col-sm-4">
                <label  class="col-sm-3 control-label">灾害类型</label>
                <div class="col-sm-9">
                    <g:select class="form-control" name="type" id="type" from="${[ "高风险", "中风险", "高中风险"]}" value="${params?.type}" noSelection="${["": '全部']}"/>
                </div>
            </div>
                </div>
                <div class="row">

                    <div class="form-group col-sm-4">
                        <label class="col-sm-3 control-label">日期</label>
                        <div class="col-sm-9 input-daterange input-group p-r-n"  id="datepicker" style="width: 75%;">
                            <input type="text" class=" form-control " placeholder="开始时间"
                                   value="${params?.birthdayStart}" name="birthdayStart" id="birthdayStart" style="text-align: left" />
                            <span class="input-group-addon">至</span>
                            <input type="text" class=" form-control " placeholder="结束时间"
                                   value="${params?.birthdayEnd}" name="birthdayEnd" id="birthdayEnd" style="text-align: left" />
                        </div>
                    </div>



                </div>
            </div>
        </g:form>
    </div>
    </div>

    <div class="row">
        <div class="hpanel hgreen">
            <div class="panel-heading">
                <div class="panel-tools">
                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                </div>
                全部舆情预警列表
            </div>
            <div class="panel-body no-padding">
                <div class="table-responsive">
                    <table cellpadding="1" cellspacing="1" class="table table-striped table-bordered table-hover text-center" id="estateTable">
                        <thead>
                        <tr>
                            <g:sortableColumn property="externalId" title="主题"  class="col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="buildingType" title="公布日期"  class="col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="city" title="查看次数"  class="col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="district" title="内容"   class="col-md-1 text-center tdColor" params="${params}"/>
                            <g:sortableColumn property="sourceAddress" title="查看原文路径"  class=" col-md-1 text-center tdColor" params="${params}"/>
                            <th colspan="2" class="col-md-1 text-center sortable" style="color: #34495e;">操作项</th>
                        </tr>
                        </thead>
                        <tbody>
                        %{--<g:each in="${collateralList}">--}%
                            <tr>
                                <td class="text-center"><a style="color: #3498DB" href="/riskWarning/publicOpinionShow?id=1" >广州市天河小区突发火灾</a></td>
                                <td class="text-center">2017-04-30</td>
                                <td class="text-center">20</td>
                                <td class="text-center">广州市天河小区突发火灾</td>
                                <td class="text-center">http://news.163.com/16/0323/05/BIQOTA3100014AED.html</td>
                                <td class="text-center">
                                    <div style="margin-bottom: 2px;">
                                        <a href="${it?.estate?.id}" class="btn btn-xs btn-outline btn-success handleButton">
                                            已处置
                                        </a>
                                    </div>
                                </td>
                                <td class="text-center">
                                    <a href="${it?.estate?.id}" class="btn btn-xs btn-outline btn-danger deleteButton" style="width: 52px; margin-top: 2px;">
                                        删除
                                    </a>
                                </td>
                                </td>
                            </tr>
                        <tr>
                            <td class="text-center"><a style="color: #3498DB" href="/riskWarning/publicOpinionShow?id=2" >广州鞋业商圈内发生火灾</a></td>
                            <td class="text-center">2018-07-04</td>
                            <td class="text-center">15</td>
                            <td class="text-center">广州鞋业商圈内一烂尾高楼发生火灾 </td>
                            <td class="text-center">http://china.caixin.com/2013-12-16/100617691.html</td>
                            <td class="text-center">
                                <div style="margin-bottom: 2px;">
                                    <a href="${it?.estate?.id}" class="btn btn-xs btn-outline btn-success handleButton">
                                        已处置
                                    </a>
                                </div>
                            </td>
                            <td class="text-center">
                                <a href="${it?.estate?.id}" class="btn btn-xs btn-outline btn-danger deleteButton" style="width: 52px; margin-top: 2px;">
                                    删除
                                </a>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-center"><a style="color: #3498DB" href="/riskWarning/publicOpinionShow?id=3" >海珠区东晓南路瑞宝村瑞宝新城市场发生火灾</a></td>
                            <td class="text-center">2018-06-15</td>
                            <td class="text-center">45</td>
                            <td class="text-center">广州市海珠区一纺织品仓库发生大火 黑烟冲天 </td>
                            <td class="text-center">http://news.cnr.cn/native/gd/20151003/t20151003_520046136.shtml</td>
                            <td class="text-center">
                                <div style="margin-bottom: 2px;">
                                    <a href="${it?.estate?.id}" class="btn btn-xs btn-outline btn-success handleButton">
                                        已处置
                                    </a>
                                </div>
                            </td>
                            <td class="text-center">
                                <a href="${it?.estate?.id}" class="btn btn-xs btn-outline btn-danger deleteButton" style="width: 52px; margin-top: 2px;">
                                    删除
                                </a>
                            </td>
                        </tr>

                        %{--</g:each>--}%
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="panel-footer">
                <div class="pagination">
                    %{--<g:paginate action="index" total="${collateralCount ?: 0}" params="${params}"/>--}%
                </div>
            </div>
        </div>
    </div>

</div>

<script>

    $(function () {
        $('#datepicker').datepicker({
            language: 'zh-CN'
        });
        $("#datepicker").on("changeDate", function(event) {
            $("#my_hidden_input").val(
                $("#datepicker").datepicker('getFormattedDate')
            )
        });

        $('.input-group.date').datepicker({ });
        $('.input-daterange').datepicker({ });
    });



    $(".handleButton").click(function(event){
        event.preventDefault();
        var id = $(this).attr("href");
        swal({
                title: "该笔押品已经完成预警处置吗？",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: true
            },
            function(){
                $.ajax({
                    url:'',
                    data:{
                        id:id
                    },
                    type:"post",
                    success:function(data)
                    {
                        if(data.status=="success"){
                            window.location.href="/riskWarning/dealIndex"
                        }else{
                            swal("已处置失败，请稍后重试", "", "error");
                        }
                    }
                })

            });
    });
    $(".deleteButton").click(function(event){
        event.preventDefault();
        var id = $(this).attr("href");
//        var $this = $(this);
        swal({
                title: "确定删除该笔押品的预警处置吗？",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: true
            },
            function(){
                $.ajax({
                    url:'',
                    data:{
                        id:id
                    },
                    type:"post",
                    success:function(data)
                    {
                        if(data.status=="success"){
                            $("#searchBtn").click();
//                            window.location.reload();//刷新页面
//                            var link = $this.parents("tr");
//                            link.remove();//删除行
                        }else{
                            swal("删除失败，请稍后重试", "", "error");
                        }
                    }
                })
            })
    });
    //城市切换
    $("#city").bind("change", function(){
        $("#district option").remove();
        $("#s2id_district span:first").html("请选择行政区");
        var city = $("#city").val();
        $("#district").append("<option value='-1' >请选择行政区</option>");
        if(city=='-1'){
            return
        }
        $.ajax({
            url: "/estate/districtList",
            type: "POST",
            data: {'city': city} ,
            success: function(result){
                for(var i=0; i < result.districtList.length; i++){
                    $("#district").append("<option value=" + result.districtList[i].zoneNumber + ">" + result.districtList[i].name + "</option>")
                }
            }
        });
    });
    // $("#city").change();
    //条件重置
    $("#resetBtn").click(function () {
        $("#s2id_city span:first").html("请选择城市");
        $("#city").val("");
        $("#communityName").val("");
        $("#s2id_type span:first").html("全部");
        $("#type").val("");
        $("#birthdayEnd").val("");
        $("#birthdayStart").val("");

    });
    //查看地图
    function searchMap() {
        var risk=$("#risk").val(),
            city=$('#city').val(),
            district=$('#district').val(),
            precinct=$('#precinct').val(),
            inputData={
                risk:risk,
                city:city,
                district:district,
                precinct:precinct
            };
        if(city=="-1"){
            toastr.error('请选择城市！');
            return
        }
        //window.location.href="/map/cluster?currentMap=clusterMap&flag=true&city="+$("#city").val()+"&district="+$("#district").val()+"&communityId="+$("#communityId").val();
        window.location.href="/newMap/cluster?currentMap=clusterMap&city="+$("#city").val()+"&district="+$("#district").val()+"&communityId="+$("#communityId").val();
    }
</script>

</body>
</html>
